﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Web_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        Bestlife.ERP.Entities.E_User_Login user = new Bestlife.ERP.Entities.E_User_Login();
        Bestlife.ERP.BusinessRules.Shopping_Cart CartData = new Bestlife.ERP.BusinessRules.Shopping_Cart();
        user.User_Name1 = TextBoxUserName.Text;
        user.Password1 = TextBoxPassword.Text;
        Session["user"] = TextBoxUserName.Text;

        
        bool b = Bestlife.ERP.BusinessRules.B_User_Login.user(user);
        if (Session["cart"] != null)
        {
            CartData = (Bestlife.ERP.BusinessRules.Shopping_Cart)Session["cart"];
            if (CartData.Items.Count > 0)
            {
                Response.Redirect("CartCheck.aspx");
            }
            else
            {
                if (b)
                {
                    Response.Redirect("Home.aspx");
                }
                else
                {
                    Invalid.Text = "Username And Password is Incorrect !";
                }

            }

        }
        else if (b)
        {
            Response.Redirect("Home.aspx");
        }
             
        // Response.Redirect("404.aspx");
    }
    protected void ASPxButton2_Click(object sender, EventArgs e)
    {
       Response.Redirect("Registration.aspx");
    }
}